<template>
    <div>
        <Modal v-model="modalSs11002" :title=title width="1200" cancel-text="关闭" style="position:relative;">
            <Form ref="dataSs11002" :model="dataSs11002" :rules="ruleSs11002" inline :label-width="180"  :disabled=true>
                <table style="width:100%;">
                    <tr>
                        <td style="width:33%;" colspan="2">
                            <FormItem label="姓名" prop="azcp0003">
                                <Input v-model="dataSs11002.azcp0003" placeholder="" class="itemStyle"  />
                            </FormItem>
                        </td>
                        <td style="width:33%;" colspan="2">
                            <FormItem label="与申请人关系" prop="azcp0517">
                                <Select v-model="dataSs11002.azcp0517" placeholder="" class="itemStyle" >
                                    <Option v-for="item in relationList" :value="item.value" :key="item.value">{{
                                        item.label }}
                                    </Option>
                                </Select>
                            </FormItem>
                        </td>
                        <td rowspan="4" style="width:34%;" colspan="2">
                            <img :src="header" alt="..." style="height: 160px; width:120px;margin-left:50px;">
                            <div class="headerBtnDiv" >
                              {{checkBtnName}}
                            </div>
                        </td>
                    </tr>
                    <tr>
                        <td colspan="2">
                            <FormItem label="证件类型" prop="azcp0002">
                                <dictSelect :sel_val='dataSs11002.azcp0002' :bindData.sync="dataSs11002.azcp0002"
                                            dictCode="certificatetype" showKeys="1" class="itemStyle" />
                            </FormItem>
                        </td>
                        <td colspan="2">
                            <FormItem label="证件号码" prop="azcp0001">
                                <Input v-model="dataSs11002.azcp0001" placeholder="" class="itemStyle"
                                       @on-blur="checkIdcard()" />
                            </FormItem>
                        </td>
                    </tr>
                    <tr>
                        <td colspan="2">
                            <FormItem label="国籍" prop="azcp0006">
                                <dictSelect :sel_val='dataSs11002.azcp0006' :bindData.sync="dataSs11002.azcp0006"
                                            dictCode="nationality" class="itemStyle" />
                            </FormItem>
                        </td>
                        <td colspan="2">
                            <FormItem label="户籍类别" prop="azcp0013">
                                <dictSelect :sel_val='dataSs11002.azcp0013' :bindData.sync="dataSs11002.azcp0013"
                                            dictCode="registertype" class="itemStyle" />
                            </FormItem>
                        </td>
                    </tr>
                    <tr>
                        <td colspan="2">
                            <FormItem label="民族" prop="azcp0007">
                                <dictSelect :sel_val='dataSs11002.azcp0007' :bindData.sync="dataSs11002.azcp0007"
                                            dictCode="nation" class="itemStyle" />
                            </FormItem>
                        </td>
                        <td colspan="2">
                            <FormItem label="文化程度" prop="azcp0008">
                                <dictSelect :sel_val='dataSs11002.azcp0008' :bindData.sync="dataSs11002.azcp0008"
                                            dictCode="education" class="itemStyle" />
                            </FormItem>
                        </td>
                    </tr>
                    <tr>
                        <td colspan="2">
                            <FormItem label="政治面貌" prop="azcp0012">
                                <dictSelect :sel_val='dataSs11002.azcp0012' :bindData.sync="dataSs11002.azcp0012"
                                            dictCode="politicaloutlook" class="itemStyle" />
                            </FormItem>
                        </td>
                        <td colspan="2">
                            <FormItem label="婚姻状况" prop="azcp0010">
                                <dictSelect :sel_val='dataSs11002.azcp0010' :bindData.sync="dataSs11002.azcp0010"
                                            dictCode="maritalstatus" class="itemStyle" />
                            </FormItem>
                        </td>
                        <td colspan="2">
                            <FormItem label="特定救助对象类型" prop="azcp0547">
                                <dictSelect :sel_val='dataSs11002.azcp0547' :bindData.sync="dataSs11002.azcp0547"
                                            dictCode="specificrelief" class="itemStyle" />
                            </FormItem>
                        </td>
                    </tr>
                    <tr>
                        <td colspan="2">
                            <FormItem label="学业状况" prop="azcp0539">
                                <dictSelect :sel_val='dataSs11002.azcp0539' :bindData.sync="dataSs11002.azcp0539"
                                            dictCode="educationstatus" class="itemStyle"  />
                            </FormItem>
                        </td>
                        <td colspan="2">
                            <FormItem label="就业状况" prop="azcp0540">
                                <dictSelect :sel_val='dataSs11002.azcp0540' :bindData.sync="dataSs11002.azcp0540"
                                            dictCode="workstatus" class="itemStyle"  />
                            </FormItem>
                        </td>
                        <td colspan="2">
                            <FormItem label="职业" prop="azcp0011">
                                <dictSelect :sel_val='dataSs11002.azcp0011' :bindData.sync="dataSs11002.azcp0011"
                                            dictCode="occupationtype" class="itemStyle"  />
                            </FormItem>
                        </td>
                    </tr>
                    <tr>
                        <td colspan="2">
                            <FormItem label="健康状况" prop="azcp0009">
                                <dictSelect :sel_val='dataSs11002.azcp0009' :bindData.sync="dataSs11002.azcp0009"
                                            dictCode="health" @changeState="setHealthState01" class="itemStyle"  />
                            </FormItem>
                        </td>
                        <td colspan="2">
                            <FormItem label="劳动能力丧失情况" prop="azcp0502">
                                <dictSelect :sel_val='dataSs11002.azcp0502' :bindData.sync="dataSs11002.azcp0502"
                                            dictCode="workability" class="itemStyle"  />
                            </FormItem>
                        </td>
                        <td colspan="2">
                            <FormItem label="是否残疾" prop="azcp0503">
                                <dictSelect :sel_val='dataSs11002.azcp0503' :bindData.sync="dataSs11002.azcp0503"
                                            dictCode="yesorno" @changeState="setDisabilityState01" class="itemStyle"  />
                            </FormItem>
                        </td>
                    </tr>
                    <tr>
                        <td colspan="2">
                            <FormItem label="残疾类别" prop="azcp0504" :rules="ruleAzcp0504">
                                <dictSelect :sel_val='dataSs11002.azcp0504' :bindData.sync="dataSs11002.azcp0504"
                                            dictCode="disabilitytype"  class="itemStyle"  />
                            </FormItem>
                        </td>
                        <td colspan="2">
                            <FormItem label="残疾等级" prop="azcp0505" :rules="ruleAzcp0505">
                                <dictSelect :sel_val='dataSs11002.azcp0505' :bindData.sync="dataSs11002.azcp0505"
                                            dictCode="disabilityclass"  class="itemStyle"  />
                            </FormItem>
                        </td>
                        <td colspan="2">
                            <FormItem label="残疾等级评定时间" prop="azcp0506">
                                <DatePicker type="date" v-model="dataSs11002.azcp0506"
                                            class="itemStyle"  />
                            </FormItem>
                        </td>
                    </tr>
                    <tr>
                        <td colspan="2">
                            <FormItem label="重病名称" prop="azcp0525" :rules="ruleAzcp0525">
                                <Input v-model="dataSs11002.azcp0525" placeholder=""
                                       class="itemStyle"  />
                            </FormItem>
                        </td>
                        <td colspan="2">
                            <FormItem label="重病病种" prop="azcp0524" :rules="ruleAzcp0524">
                                <dictSelect :sel_val='dataSs11002.azcp0524' :bindData.sync="dataSs11002.azcp0524"
                                            dictCode="sicknesstype"  class="itemStyle"  />
                            </FormItem>
                        </td>
                        <td colspan="2">
                            <FormItem label="重病患病时间" prop="azcp0522">
                                <DatePicker type="date" v-model="dataSs11002.azcp0522" style="width: 178px"
                                             class="itemStyle"  />
                            </FormItem>
                        </td>
                    </tr>
                    <tr>
                        <td colspan="2">
                            <FormItem label="是否伤残" prop="azcp0507">
                                <dictSelect :sel_val='dataSs11002.azcp0507' :bindData.sync="dataSs11002.azcp0507"
                                            dictCode="yesorno" @changeState="setMaimState" class="itemStyle"  />
                            </FormItem>
                        </td>
                        <td colspan="2">
                            <FormItem label="伤残等级" prop="azcp0508" :rules="ruleAzcp0508">
                                <dictSelect :sel_val='dataSs11002.azcp0508' :bindData.sync="dataSs11002.azcp0508"
                                            dictCode="invalidismclass"  class="itemStyle"  />
                            </FormItem>
                        </td>
                        <td colspan="2">
                            <FormItem label="伤残等级评定时间" prop="azcp0509">
                                <DatePicker type="date" v-model="dataSs11002.azcp0509" style="width: 178px"
                                             class="itemStyle"  />
                            </FormItem>
                        </td>
                    </tr>
                    <tr>
                        <td colspan="2">
                            <FormItem label="生活自理能力" prop="azcp0513">
                                <dictSelect :sel_val='dataSs11002.azcp0513' :bindData.sync="dataSs11002.azcp0513"
                                            dictCode="selfcareability" class="itemStyle"  />
                            </FormItem>
                        </td>
                        <td colspan="2">
                            <FormItem label="护理类型" prop="azcp0546">
                                <dictSelect :sel_val='dataSs11002.azcp0546' :bindData.sync="dataSs11002.azcp0546"
                                            dictCode="nursetype" class="itemStyle"  />
                            </FormItem>
                        </td>
                        <td colspan="2">
                            <FormItem label="优抚对象类别" prop="azcp0520">
                                <dictSelect :sel_val='dataSs11002.azcp0520' :bindData.sync="dataSs11002.azcp0520"
                                            dictCode="specialcare" class="itemStyle"  />
                            </FormItem>
                        </td>
                    </tr>
                    <tr>
                        <td colspan="2">
                            <FormItem label="是否军休干部" prop="azcp0018">
                                <dictSelect :sel_val='dataSs11002.azcp0018' :bindData.sync="dataSs11002.azcp0018"
                                            dictCode="yesorno" class="itemStyle"  />
                            </FormItem>
                        </td>
                        <td colspan="2">
                            <FormItem label="是否收养对象" prop="azcp0023">
                                <dictSelect :sel_val='dataSs11002.azcp0023' :bindData.sync="dataSs11002.azcp0023"
                                            dictCode="yesorno" class="itemStyle"  />
                            </FormItem>
                        </td>
                        <td colspan="2">
                            <FormItem label="是否流浪乞讨救助人员" prop="azcp0024">
                                <dictSelect :sel_val='dataSs11002.azcp0024' :bindData.sync="dataSs11002.azcp0024"
                                            dictCode="yesorno" class="itemStyle"  />
                            </FormItem>
                        </td>
                    </tr>
                    <tr>
                        <td colspan="2">
                            <FormItem label="是否三无人员" prop="azcp0512">
                                <dictSelect :sel_val='dataSs11002.azcp0512' :bindData.sync="dataSs11002.azcp0512"
                                            dictCode="yesorno" class="itemStyle"  />
                            </FormItem>
                        </td>
                        <td colspan="2">
                            <FormItem label="是否福利院入住对象" prop="azcp0025">
                                <dictSelect :sel_val='dataSs11002.azcp0025' :bindData.sync="dataSs11002.azcp0025"
                                            dictCode="yesorno" class="itemStyle"  />
                            </FormItem>
                        </td>
                        <td colspan="2">
                            <FormItem label="是否复原退伍军人" prop="azcp0027">
                                <dictSelect :sel_val='dataSs11002.azcp0027' :bindData.sync="dataSs11002.azcp0027"
                                            dictCode="yesorno" class="itemStyle"  />
                            </FormItem>
                        </td>
                    </tr>
                    <tr>
                        <td colspan="2">
                            <FormItem label="现居住地开始居住时间" prop="azcp0501">
                                <DatePicker v-model="dataSs11002.azcp0501" type="date" class="itemStyle"  />
                            </FormItem>
                        </td>
                        <td colspan="2">
                            <FormItem label="联系电话" prop="azcp0514">
                                <Input v-model="dataSs11002.azcp0514" placeholder="" class="itemStyle"  />
                            </FormItem>
                        </td>
                        <td colspan="2">
                            <FormItem label="养老保险参保类型" prop="azcp0526">
                                <dictSelect :sel_val='dataSs11002.azcp0526' :bindData.sync="dataSs11002.azcp0526"
                                            dictCode="pensiontype" class="itemStyle"  />
                            </FormItem>
                        </td>
                    </tr>
                    <tr>
                        <td colspan="2">
                            <FormItem label="当前是否已参加医疗保险" prop="azcp0527">
                                <dictSelect :sel_val='dataSs11002.azcp0527' :bindData.sync="dataSs11002.azcp0527"
                                            dictCode="insuranceornot" @changeState="setMedicalInsuranceState"
                                            class="itemStyle"  />
                            </FormItem>
                        </td>
                        <td colspan="2">
                            <FormItem label="医疗保险参保类型" prop="azcp0528" :rules="ruleAzcp0528">
                                <dictSelect :sel_val='dataSs11002.azcp0528' :bindData.sync="dataSs11002.azcp0528"
                                            dictCode="insuredtype"   class="itemStyle"  />
                            </FormItem>
                        </td>
                        <td colspan="2">
                            <FormItem label="是否参加失业保险" prop="azcp0531">
                                <dictSelect :sel_val='dataSs11002.azcp0531' :bindData.sync="dataSs11002.azcp0531"
                                            dictCode="yesorno" class="itemStyle"  />
                            </FormItem>
                        </td>
                    </tr>
                    <tr>
                        <td colspan="2">
                            <FormItem label="社保编号或新农合编号" prop="azcp0529">
                                <Input v-model="dataSs11002.azcp0529" placeholder="" class="itemStyle"  />
                            </FormItem>
                        </td>
                        <td colspan="2">
                            <FormItem label="社保卡号或新农合卡号" prop="azcp0530">
                                <Input v-model="dataSs11002.azcp0530" placeholder="" class="itemStyle"  />
                            </FormItem>
                        </td>
                        <td colspan="2">
                            <FormItem label="所属资源枯竭关破企业名称" prop="azcp0541">
                                <dictSelect :sel_val='dataSs11002.azcp0541' :bindData.sync="dataSs11002.azcp0541"
                                            dictCode="brokenenterprise" class="itemStyle"  />
                            </FormItem>
                        </td>
                    </tr>
                    <tr>
                        <td colspan="2">
                            <FormItem label="是否纳入扶贫建档立卡对象" prop="azcp0545">
                                <dictSelect :sel_val='dataSs11002.azcp0545' :bindData.sync="dataSs11002.azcp0545"
                                            dictCode="yesorno" class="itemStyle"  />
                            </FormItem>
                        </td>
                        <td colspan="2">
                            <FormItem label="是否法人代表" prop="azcp0579">
                                <dictSelect  :sel_val='dataSs11002.azcp0579' :bindData.sync="dataSs11002.azcp0579"
                                            dictCode="yesorno" class="itemStyle"  />
                            </FormItem>
                        </td>
                        <td colspan="2">
                            <FormItem label="企业或社会组织名称" prop="azcp0580">
                                <Input v-model="dataSs11002.azcp0580" placeholder="" class="itemStyle"  />
                            </FormItem>
                        </td>
                    </tr>
                    <tr>
<!--                        <td colspan="2">-->
<!--                            <FormItem label="企业或社会组织地址" prop="azcp0580">-->
<!--                                <Input v-model="dataSs11002.azcp0580" placeholder="" class="itemStyle"  />-->
<!--                            </FormItem>-->
<!--                        </td>-->
<!--                        <td colspan="2">-->
<!--                            <FormItem label="注册资金(万元)" prop="azcp0582">-->
<!--                                <Input v-model="dataSs11002.azcp0582" placeholder="" class="itemStyle"  />-->
<!--                            </FormItem>-->
<!--                        </td>-->
                        <td colspan="2">
                            <FormItem label="单亲丧偶(失踪、服刑)" prop="azcp0585">
                                <dictSelect :sel_val='dataSs11002.azcp0585' :bindData.sync="dataSs11002.azcp0585"
                                            dictCode="yesorno" class="itemStyle"  />
                            </FormItem>
                        </td>
                        <td colspan="2">
                            <FormItem label="刑满释放人员" prop="azcp0586">
                                <dictSelect :sel_val='dataSs11002.azcp0586' :bindData.sync="dataSs11002.azcp0586"
                                            dictCode="yesorno" class="itemStyle"  />
                            </FormItem>
                        </td>
                        <td colspan="2">
                            <FormItem label="是否扶贫人口" prop="azcp0587">
                                <dictSelect  :sel_val='dataSs11002.azcp0587' :bindData.sync="dataSs11002.azcp0587"
                                            dictCode="yesorno" class="itemStyle"  />
                            </FormItem>
                        </td>
                    </tr>
                    <tr>
                        <!--                    户籍区划功能-->
                        <td colspan="4">
                            <FormItem label="户籍地址">
                                <Ss01003Tag :bindshengjiData.sync="shengQuHua"
                                            :bindshijiData.sync="shiQuHua"
                                            :shengji_value="shengQuHua"
                                            :shiji_value="shiQuHua"
                                            :shengji_disabled="hujiquhuaDisabled"
                                            :shiji_disabled="hujiquhuaDisabled">
                                </Ss01003Tag>
                            </FormItem>
                        </td>
                    </tr>
                    <tr>
                        <td colspan="2" v-if="dataSs11002.azcp0583!=null&&dataSs11002.azcp0583!=''">
                            <FormItem label="单人保类型" prop="azcp0583">
                                <dictSelect :sel_val='dataSs11002.azcp0583' :bindData.sync="dataSs11002.azcp0583"
                                            dictCode="alonetype" class="itemStyle"  />
                            </FormItem>
                        </td>
                        <td colspan="2" v-if="dataSs11002.azcp0584!=null&&dataSs11002.azcp0584!=''">
                            <FormItem label="建档立卡类型" prop="azcp0584">
                                <dictSelect :sel_val='dataSs11002.azcp0584' :bindData.sync="dataSs11002.azcp0584"
                                            dictCode="filing_type" class="itemStyle"  />
                            </FormItem>
                        </td>
                        <td colspan="2" hidden>
                            <FormItem label="是否本地户籍" prop="azcp0591">
                                <dictSelect :sel_val='dataSs11002.azcp0591' :bindData.sync="dataSs11002.azcp0591"
                                             dictCode="yesorno" class="itemStyle"  />
                            </FormItem>
                        </td>
                    </tr>
                    <tr>
                        <td colspan="4">
                            <FormItem label="证件上传类型">
                                <RadioGroup v-model="dataSs11002.azcp0593" type="button" @on-change="showUpload" >
                                    <Radio label="0" >身份证正反面照片上传</Radio>
                                    <Radio label="1" >户口簿个人页照片上传</Radio>
                                </RadioGroup>
                            </FormItem>
                        </td>
                        <td colspan="2">
                        </td>
                    </tr>
                </table>
                <Row class="" style="height:250px;line-height:250px">
                    <Col span="24" style="text-align: center" class="">
                        <Row v-if="identityCardVisible">
                            <Col span="10" style="text-align: center" class="">
                                <div class="imgBackColor">
                                    <img :src="sfz_z" alt="..." class="head-img1">
                                </div>
                            </Col>
                            <Col span="2" style="text-align: center" class="">
                                <div class="positiveTDiv"  >
                                    正面上传
                                </div>
                                <!--
                                <div class="positiveBDiv">
                                    <span>正面拍摄</span>
                                </div>
                                -->
                            </Col>
                            <Col span="10" style="text-align: center" class="">
                                <div class="imgBackColor">
                                    <img :src="sfz_f" alt="..." class="head-img1">
                                </div>
                            </Col>
                            <Col span="2" style="text-align: center" class="">
                                <div class="positiveTDiv"  >
                                    反面上传
                                </div>
                                <!--
                                <div class="positiveBDiv">
                                    <span>反面拍摄</span>
                                </div>
                                -->
                            </Col>
                        </Row>
                        <Row v-if="householdRegisterVisible">
                            <Col span="8" style="text-align: center" class="">
                                <div class="imgBackColor">
                                    <img :src="hkb" alt="..." class="head-img1">
                                </div>
                            </Col>
                            <Col span="4" style="text-align: center" class="">
                                <div class="positiveTDiv" >
                                    户口簿上传
                                </div>
                            </Col>
                        </Row>
                    </Col>
                </Row>
            </Form>
            <div slot="footer">
                <Button type="text" size="large" @click="modalSs11002 = false">关闭</Button>
            </div>
        </Modal>

        <Modal v-model="up_pic_mol" title="图片上传" @on-ok="changeToView" :closable="false">
            <Upload multiple action="/api/ac/hdplugin/ossService/uploadBase64"
                    :before-upload="beforeUpload">
                <Button icon="ios-cloud-upload-outline">上传图片</Button>
                <span style="margin-left: 200px">建议上传小于8M的图片</span>
            </Upload>
            <img :src="temp_photo" style="width: 100%"  />
        </Modal>
        <Modal v-model="picPreviewMol.preShow" :closable="false" :styles="{top: '20px'}" width="532">
            <Carousel v-model="picPreviewMol.picIndex" style="width:500px" dots="outside" trigger="hover" >
                <CarouselItem class="centerimg" v-for="(imginfo, index) in picPreviewMol.pic_urls" :key="index">
                    <img :src="imginfo" class="pre_img_style"  />
                </CarouselItem>
            </Carousel>
            <div slot="footer" style="text-align: center">
                <Button @click="picPreviewMol.preShow=false">关闭</Button>
            </div>
        </Modal>

        <Modal v-model="ss00011ModelShow" style="margin-top:20px;" :title="yzModalTitle" :mask-closable="false"
               width="800">
            <Ss00011Check
                    :azcp0001="dataSs11002.azcp0001"
                    :azcp0003="dataSs11002.azcp0003"
                    :ss12001Id="dataSs11002.ss12001Id"
                    :isRequestBackstage="ss00011ModelShow"
                    :batchNumber.sync="batchNumber"
                    :validateInfo.sync="validateInfo"
                    :validateStatus.sync="validateStatus"
            />
        </Modal>
    </div>
</template>

<script>
  import { getSign, createUpLoadFiles,compressImg } from '@/api/common'
  import dictSelect from '@/components/dictSelect/dictSelect.vue'
  import pic_hkb from '@/assets/images/hkb.jpg'
  import pic_sfz_z from '@/assets/images/sfz_z.jpg'
  import pic_sfz_f from '@/assets/images/sfz_f.jpg'
  import pic_header from '@/assets/images/header.jpeg'
  import { getAction, postAction } from '@/api/request'
  import DateFormat from '@/plugins/format.js'
  import { IdentityCodeValid, getAgeByIdcardByHD } from '@/plugins/idcardValid.js'
  import Ss00011Check from '@/components/system/ss00011-check'
  import Ss01003Tag from '@/components/system/ss01003-select'// 户籍区划功能


  export default {
    components: {
      dictSelect,
      Ss00011Check,
        Ss01003Tag //户籍区划功能
    },
    data () {
      return {
          shengQuHua: '', //户籍区划功能
          shiQuHua: '', //户籍区划功能
          hujiquhuaDisabled: false, //户籍区划功能
        householdRegisterState: true, //户口簿是否可上传，默认false
        ss11001Id: '',
        temp_photo: '',
        upPicData: {},
        imgType: '',
        picPreviewMol: {
          preShow: false,
          pic_urls: [],
          picIndex: 0
        },
        up_pic_mol: false,
        url: {
          insertSs11002: '/api/ac/subsistence/ss11002Service/insertData',
          updateSs11002: '/api/ac/subsistence/ss11002Service/updateData',
        },
        identityCardVisible: true,
        householdRegisterVisible: false,
        title: '',
        dataSs11002: {
          type: '1', // 保障人员类型
          id: '',
          azcp0507: '',
          ss12001Id: '',
          azcp0503: '',
          azcp0505: '',
          azcp0504: '',
          azcp0502: '',
          azcp0543: '',
          azcp0027: '',
          azcp0024: '',
          azcp0541: '',
          azcp0025: '',
          azcp0547: '',
          azcp0545: '',
          azcp0023: '',
          azcp0540: '',
          azcp0539: '',
          azcp0013: '',
          azcp0530: '',
          azcp0531: '',
          azcp0018: '',
          azcp0011: '',
          azcp0012: '',
          azcp0010: '',
          azcp0529: '',
          azcp0527: '0',
          azcp0002: '',
          azcp0003: '',
          azcp0520: '',
          azcp0008: '',
          azcp0525: '',
          azcp0009: '',
          azcp0526: '',
          azcp0006: '',
          azcp0007: '',
          azcp0524: '',
          azcp0001: '',
          azcp0517: '',
          azcp0514: '',
          azcp0512: '',
          azcp0513: '',
          azcp0020: '',
          azcp0510: '',
          azcp0518: '',
          azcp0519: '',
          azcp0523: '',
          azcp0508: '',
          azcp0579: '',
          azcp0581: '',
          azcp0580: '',
          azcp0582: '',
          azcp0585: '',
          azcp0584: '',
          azcp0586: '',
          azcp0587: '',
          azcp0583: '',
          azcp0591: '',
          azcp0551: '',
          azcp0552: '',
          azcp0593: '',
          azcp0594: '',
          azcp0578:'0',
          azcp0500: ''
        },
        relationList: [], //保障人员家庭关系
        modalSs11002: false, //保障人员model显隐
        healthState01: false,  //保障人员健康状况联动状态
        disabilityState01: false, //保障人员残疾联动状态
        maimState: false,  //伤残联动状态
        medicalInsuranceState: true, //医保联动状态
        fieldsToValidate01: ['azcp0003', 'azcp0517', 'azcp0002', 'azcp0001', 'azcp0013', 'azcp0007', 'azcp0008', 'azcp0012', 'azcp0010',
          'azcp0540', 'azcp0009', 'azcp0502', 'azcp0503', 'azcp0504', 'azcp0505', 'azcp0525', 'azcp0524', 'azcp0508', 'azcp0513', 'azcp0512',
          'azcp0526', 'azcp0527', 'azcp0528', 'azcp0531', 'azcp0586'],
        ruleSs11002: {
          azcp0003: [
            { required: true, message: '请输入姓名', trigger: 'blur' }
          ],
          azcp0517: [
            { required: true, message: '请选择与申请人关系', trigger: 'blur' }
          ],
          azcp0002: [
            { required: true, message: '请选择证件类型', trigger: 'blur' }
          ],
          azcp0001: [
            { required: true, message: '请填写证件号码', trigger: 'blur' }
          ],
          azcp0013: [
            { required: true, message: '请选择户籍类别', trigger: 'blur' }
          ],
          azcp0007: [
            { required: true, message: '请选择民族', trigger: 'blur' }
          ],
          azcp0008: [
            { required: true, message: '请选择文化程度', trigger: 'blur' }
          ],
          azcp0012: [
            { required: true, message: '请选择政治面貌', trigger: 'blur' }
          ],
          azcp0010: [
            { required: true, message: '请选择婚姻状况', trigger: 'blur' }
          ],
          azcp0540: [
            { required: true, message: '请选择就业状况', trigger: 'blur' }
          ],
          azcp0009: [
            { required: true, message: '请选择健康状况', trigger: 'blur' }
          ],
          azcp0502: [
            { required: true, message: '请选择劳动能力丧失情况', trigger: 'blur' }
          ],
          azcp0503: [
            { required: true, message: '请选择是否残疾', trigger: 'blur' }
          ],
          azcp0513: [
            { required: true, message: '请选择生活自理能力', trigger: 'blur' }
          ],
          azcp0512: [
            { required: true, message: '请选择是否三无人员', trigger: 'blur' }
          ],
          azcp0526: [
            { required: true, message: '请选择养老保险参保类型', trigger: 'blur' }
          ],
          azcp0527: [
            { required: true, message: '请选择当前是否已参加医疗保险', trigger: 'blur' }
          ],
          azcp0531: [
            { required: true, message: '请选择是否参加失业保险', trigger: 'blur' }
          ],
          azcp0586: [
            { required: true, message: '请选择是否刑满释放人员', trigger: 'blur' }
          ],
        },
        ruleAzcp0504: { message: '请选择残疾类别', trigger: 'blur' },
        ruleAzcp0505: { message: '请选择残疾等级', trigger: 'blur' },
        ruleAzcp0524: { message: '请选择重病病种', trigger: 'blur' },
        ruleAzcp0525: { message: '请填写重病名称', trigger: 'blur' },
        ruleAzcp0508: { message: '请选择伤残等级', trigger: 'blur' },
        ruleAzcp0528: { message: '请选择医疗保险类型', trigger: 'blur' },
        hkb: '',
        sfz_z: '',
        sfz_f: '',
        header: '',

        checkBtnName: '已查验',
        validateStatus: true, //查验状态 true 未查验或查验异常 false 查验通过
        //批次号
        batchNumber: '',
        validateInfo: '',
        //事前查验标题
        yzModalTitle: '',
        ss00011ModelShow: false,
      }
    },
    methods: {
      showUpload (type) { //处理证件上传类型
        let that = this
        if (type == '0') {
          that.identityCardVisible = true
          that.householdRegisterVisible = false
          that.dataSs11002.azcp0593 = '0'
        } else {
          that.identityCardVisible = false
          that.householdRegisterVisible = true
          that.dataSs11002.azcp0593 = '1'
        }
      },
      create () {
        let that = this
        that.dataSs11002 = {}
        that.title = '保障家庭成员录入'
        that.modalSs11002 = true
        that.initRelation01()
        that.handleRelationship('member')
        that.sfz_z = pic_sfz_z
        that.sfz_f = pic_sfz_f
        that.header = pic_header
        that.hkb = pic_hkb
        that.dataSs11002.azcp0500 = that.ss11001Id
        that.householdRegisterState = false
        that.showUpload('0')
      },
      async edit (record) {
        let that = this
        that.title = '保障家庭成员详情'
        if (record.azcp0517 == '01') {
          await that.handleRelationship('master')
        } else {
          await that.handleRelationship('member')
        }
        that.modalSs11002 = true
        that.dataSs11002 = Object.assign({}, record)
        that.dataSs11002.azcp0509 = new Date(record.azcp0509)
        that.initRelation01()

        if (that.dataSs11002.azcp0593 == '1') {
          let azcp0594 = that.dataSs11002.azcp0594
          if (azcp0594 != null && typeof (azcp0594) != 'undefined') {
            this.hkb = that.dataSs11002.azcp0594
          } else {
            this.hkb = pic_hkb
          }
        } else {
          let azcp0551 = that.dataSs11002.azcp0551
          if (azcp0551 != null && typeof (azcp0551) != 'undefined') {
            this.sfz_z = that.dataSs11002.azcp0551
          } else {
            this.sfz_z = pic_sfz_z
          }
          let azcp0552 = that.dataSs11002.azcp0552
          if (azcp0552 != null && typeof (azcp0552) != 'undefined') {
            this.sfz_f = that.dataSs11002.azcp0552
          } else {
            this.sfz_f = pic_sfz_f
          }
        }
        let azcp0519 = that.dataSs11002.azcp0519
        if (azcp0519 != null && typeof (azcp0519) != 'undefined') {
          this.header = that.dataSs11002.azcp0519
        } else {
          this.header = pic_header
        }
        that.showUpload(that.dataSs11002.azcp0593)
        that.checkIdcard()
        that.setCheckStatus(that.dataSs11002.azcp0578);
          that.shengShiQuHua(that.dataSs11002.azcp0591); //户籍区划功能
      },
      handleSubmitSs11002 (name) { // 保障人员信息提交
        let that = this
        let validate = true
        let err_msg = []

        for (let item of this.fieldsToValidate01) {
          this.$refs[name].validateField(item, (error) => {
            if (error) {
              validate = false
              err_msg.push(this.ruleSs11002[item][0].message)
            }
          })
        }
        if (validate) {
          let dataParam = {}
          dataParam = Object.assign({}, that.dataSs11002)
          let url = null
          if (dataParam.id == null || dataParam.id == '') {
            url = that.url.insertSs11002
          } else {
            url = that.url.updateSs11002
          }

          if (dataParam.azcp0593 == '1') {
            let azcp0594 = dataParam.azcp0594
            if (azcp0594 == null || azcp0594 == '' || typeof (azcp0594) == 'undefined') {
              that.$Message.error('请上传个人户口簿页面照片')
              return
            }
            dataParam.azcp0551 = ''
            dataParam.azcp0552 = ''
          } else {
            let azcp0551 = dataParam.azcp0551
            if (azcp0551 == null || azcp0551 == '' || typeof (azcp0551) == 'undefined') {
              that.$Message.error('请上传居民身份证正面照片')
              return
            }

            let azcp0552 = dataParam.azcp0552
            if (azcp0552 == null || azcp0552 == '' || typeof (azcp0552) == 'undefined') {
              that.$Message.error('请上传居民身份证背面照片')
              return
            }
            dataParam.azcp0594 = ''
          }

          postAction(url, dataParam).then((res) => {
            if (res.data.data.code == 1) {
              that.modalSs11002 = false
              that.$Message.success(res.data.data.msg)
              that.$emit('ok')
            } else {
              that.$Message.error(res.data.data.msg)
            }
          }).finally(() => {

          })
        } else {
          that.$Message.error(err_msg[0])
          return
        }
      },
      initRelation01 () { //初始化保障人员页面选择联动
        let that = this
        that.setDisabilityState01();
        that.setMaimState()
        that.setHealthState01()
        that.setMedicalInsuranceState()
      },
      setDisabilityState01 () { //残疾联动
        let that = this
        let value = that.dataSs11002.azcp0503
        if (value == '1') {
          that.disabilityState01 = false
          that.ruleAzcp0504 = [{ required: true, message: '请选择残疾类别', trigger: 'blur' }]
          that.ruleAzcp0505 = [{ required: true, message: '请选择残疾等级', trigger: 'blur' }]
          that.ruleSs11002.azcp0504 = that.ruleAzcp0504
          that.ruleSs11002.azcp0505 = that.ruleAzcp0505
        } else {
          that.disabilityState01 = true
          that.ruleAzcp0504 = [{ required: false }]
          that.ruleAzcp0505 = [{ required: false }]
          that.dataSs11002.azcp0504 = null
          that.dataSs11002.azcp0505 = null
          that.dataSs11002.azcp0506 = null
          delete that.ruleSs11002.azcp0504
          delete that.ruleSs11002.azcp0505
        }
      },
      setHealthState01 () {  //健康联动
        let that = this
        let value = that.dataSs11002.azcp0009
        if (value == '40') {  //重病
          that.healthState01 = false
          that.ruleAzcp0525 = [{ required: true, message: '请填写重病名称', trigger: 'blur' }]
          that.ruleAzcp0524 = [{ required: true, message: '请选择重病病种', trigger: 'blur' }]
          that.ruleSs11002.azcp0525 = that.ruleAzcp0525
          that.ruleSs11002.azcp0524 = that.ruleAzcp0524
        } else { //健康、一般、慢性病
          that.ruleAzcp0525 = [{ required: false }]
          that.ruleAzcp0524 = [{ required: false }]
          that.dataSs11002.azcp0524 = ''
          that.dataSs11002.azcp0525 = ''
          that.healthState01 = true
          delete that.ruleSs11002.azcp0525
          delete that.ruleSs11002.azcp0524
        }
      },
      setMaimState () { //伤残联动
        let that = this
        let value = that.dataSs11002.azcp0507
        if (value == '1') {
          that.maimState = false
          that.ruleAzcp0508 = [{ required: true, message: '请选择伤残等级', trigger: 'blur' }]
          that.ruleSs11002.azcp0508 = that.ruleAzcp0508
        } else {
          that.ruleAzcp0508 = [{ required: false }]
          that.dataSs11002.azcp0508 = ''
          that.dataSs11002.azcp0509 = ''
          that.maimState = true
          delete that.ruleSs11002.azcp0508
        }

      },
      setMedicalInsuranceState () {  //医保联动
        let that = this
        let value = that.dataSs11002.azcp0527
        if (value == '1') {
          that.medicalInsuranceState = false
          that.ruleAzcp0528 = [{ required: true, message: '请选择医疗保险类型', trigger: 'blur' }]
          that.ruleSs11002.azcp0528 = that.ruleAzcp0528
        } else {
          that.ruleAzcp0528 = [{ required: false }]
          that.dataSs11002.azcp0528 = ''
          that.medicalInsuranceState = true
          delete that.ruleSs11002.azcp0528
        }
      },
      async handleRelationship (type) {
        let that = this
        let param = {}
        param.pageNo = 1// 当前页数
        param.pageSize = 999//每页显示条数
        param.type = 'familyrelationship' //字典type值
        await postAction('/api/as/sc/dict/getDictList', param).then((res) => {
          if (res.data.errcode === 0) {
            if (type == 'master') {
              let arr = res.data.data.results
              for (let j = 0; j < arr.length; j++) {
                let item = arr[j]
                if (item.value != '01') {
                  arr.splice(j--, 1)
                }
              }
              that.relationList = arr
            } else {
              let arr = res.data.data.results
              for (let j = 0; j < arr.length; j++) {
                let item = arr[j]
                if (item.value == '01') {
                  arr.splice(j--, 1)
                }
              }
              that.relationList = arr
            }
          }
        })
      },
      changeToView () {
        if (this.imgType === 'Positive') {
          this.sfz_z = this.temp_photo
        } else if (this.imgType === 'Back') {
          this.sfz_f = this.temp_photo
        } else if (this.imgType === 'Personal') {
          this.hkb = this.temp_photo
        } else if (this.imgType === 'header') {
          this.header = this.temp_photo
        }
      },
      uploadPositiveImg (type) { // 正面上传
        this.temp_photo = ''
        this.imgType = type
        this.up_pic_mol = true
        if (type === 'Positive') {
          this.upPicData.fileName = '身份证正面' + DateFormat(new Date(), 'YYYYMMDDhhmmss') + '.png'
        } else if (type === 'Back') {
          this.upPicData.fileName = '身份证背面' + DateFormat(new Date(), 'YYYYMMDDhhmmss') + '.png'
        } else if (type === 'Personal') {
          this.upPicData.fileName = '户口簿个人页' + DateFormat(new Date(), 'YYYYMMDDhhmmss') + '.png'
        } else if (type === 'header') {
          this.upPicData.fileName = '个人头像' + DateFormat(new Date(), 'YYYYMMDDhhmmss') + '.png'
        }
        //this.upPicData.filePath = 'itemorder/' + '/' + this.$route.params.code
        this.upPicData.filePath = 'subsistence/' + DateFormat(new Date(), 'YYYYMMDD') + '/'
      },
      beforeAvatarUpload (file) {
        return new Promise(() => {
          compressImg(file, 200).then(res => {
            let that = this

            let index = res.indexOf('base64,') + 7
            that.upPicData.file = res.substring(index)
            that.upPic(that.upPicData)
          })
        })
      },
      beforeUpload (file) {
        const isJpgOrPng = file.type === 'image/jpeg' || file.type === 'image/png'
        if (!isJpgOrPng) {
          this.$Notice.error({ title: '上传失败', desc: '上传文件只能是 JPG 或 PNG 格式！' })
          return false
        }
        let that = this
        this.upPicData.fileName = this.upPicData.fileName + '.' + file.type.substring(6)
        if (file.size / 1024 / 1024 > 1) { // 超过1M 压缩 图片为200K
          return this.beforeAvatarUpload(file)
        }
        const reader = new FileReader()
        reader.readAsDataURL(file)
        reader.onload = () => {
          let index = reader.result.indexOf('base64,') + 7
          that.upPicData.file = reader.result.substring(index)
          that.upPic(that.upPicData)
        }
        return false
      },
      upPic (obj) {
        var time = new Date().getTime()
        this.timeStep = time.toString()
        let param = {
          filePath: obj.filePath,
          fileName: obj.fileName,
          timestamp: this.timeStep
        }
        if (param.fileName.length > 20) {
          param.fileName = param.fileName.substring(0, 20) + '.png'
        }
        getSign(param).then(res => {

          if (res.data.errcode === 0) {
            createUpLoadFiles('/api/ac/hdplugin/ossService/uploadBase64', {
              sign: res.data.data.sign,
              timestamp: this.timeStep,
              filePath: param.filePath,
              fileName: param.fileName,
              file: obj.file
            }).then(res => {

              if (res.data.errcode === 0) {
                let imgurl = res.data.data
                if (this.imgType === 'Positive') {
                  //this.dataSs11002.azcp0551url = imgurl
                  this.dataSs11002.azcp0551 = imgurl
                } else if (this.imgType === 'Back') {
                  //this.dataSs11002.azcp0552url = imgurl
                  this.dataSs11002.azcp0552 = imgurl
                } else if (this.imgType === 'Personal') {
                  this.dataSs11002.azcp0594 = imgurl
                } else if (this.imgType === 'header') {
                  this.dataSs11002.azcp0519 = imgurl
                }
                this.temp_photo = imgurl
              } else {
                this.$Notice.error({ title: '上传失败', desc: res.data.data.msg })
              }
            })
          } else {
            this.$Notice.error({ title: '上传失败', desc: res.data.data.msg })
          }
        })
      },
      checkIdcard () {  //验证身份证是否合法并判断证件上传类型
        let that = this
        let azcp0001 = that.dataSs11002.azcp0001
        if(azcp0001!=''&&typeof (azcp0001)!='undefined'){
          azcp0001 = azcp0001.toUpperCase()
          that.dataSs11002.azcp0001 = azcp0001

          if (!IdentityCodeValid(azcp0001)) {
            that.$Message.error('申请人身份证号码格式不合法')
            that.dataSs11002.azcp0001 = null
          } else {
            let age = getAgeByIdcardByHD(azcp0001, new Date())
            if (age > 18) {
              that.householdRegisterState = true
            } else {
              that.householdRegisterState = false
            }
          }
        }
      },
      checkData () { //事前查验
        let that = this
        let fieldsToValidate = ['azcp0001', 'azcp0003']
        let validate = true
        let err_msg = []
        for (let item of fieldsToValidate) {
          that.$refs['dataSs11002'].validateField(item, (error) => {
            if (error) {
              validate = false
              err_msg.push(error)
            }
          })
        }
        if (validate) {
          that.yzModalTitle = '事前查验-姓名：【' + that.dataSs11002.azcp0003 + '】 身份证号码：【' + that.dataSs11002.azcp0001 + '】'
          that.ss00011ModelShow = true
        } else {
          that.$Message.error(err_msg[0])
          return
        }
      },
      //回显查验状态
      setCheckStatus(azcp0578){
        let that=this;
        if(azcp0578=='1'){
          that.checkBtnName='已查验';
          that.validateStatus=false;
        }else{
          that.checkBtnName='未查验';
          that.validateStatus=true;
        }
      },
        // 户籍区划功能,
        shengShiQuHua(localOrNot){
            if (localOrNot == undefined || localOrNot == ''){
                this.hujiquhuaDisabled = true
                this.shengQuHua = ''
                this.shiQuHua = ''
            }else if (localOrNot == '1'){ //本地户籍的, 区划 not editable
                this.hujiquhuaDisabled = true
                this.shengQuHua = '210000000000'
                this.shiQuHua = '210100000000'
            }else if (localOrNot == '0'){ //外地户籍的, 区划 editable
                this.hujiquhuaDisabled = false
                this.shengQuHua = this.dataSs11002.azcp0602
                this.shiQuHua = this.dataSs11002.azcp0603
            }
        }
    },
    watch:{
      'dataSs11002.azcp0001': {
        handler(newName, oldName) {
          if(newName!=oldName){
            this.checkBtnName='未查验'
          }
        },
        immediate: true,
      },
      'dataSs11002.azcp0003': {
        handler(newName, oldName) {
          if(newName!=oldName){
            this.checkBtnName='未查验'
          }
        },
        immediate: true,
        // deep: true
      },
      validateStatus(newVal){
        if(newVal==false){
          this.checkBtnName='已查验'
          this.dataSs11002.azcp0578='1'
        }else{
          this.checkBtnName='未查验'
        }
      },
    }
  }
</script>

<style scoped>
    /deep/ .ivu-form-item-error-tip {
        display: none;
    }

    .ivu-form-item {
        margin-bottom: 0px;
    }

    .itemStyle {
        width: 180px
    }

    .head-img1 {
        height: 200px;
        width: 250px;
        margin-top: 15px;
    }

    .imgBackColor {
        background-color: WhiteSmoke;
        height: 250px;
    }

    .positiveTDiv {
        height: 240px;
        width: 80px;
        line-height: 240px;
        background-color: #7CCD7C;
        margin-bottom: 10px;
        color: white;
        font-size: 15px;
        font-weight: 700;
        margin-left: 15px;
        border-radius: 3px;
    }

    .positiveBDiv {
        height: 120px;
        width: 80px;
        background-color: #7CCD7C;
        line-height: 120px;
        color: white;
        font-size: 15px;
        font-weight: 700;
        margin-left: 15px;
    }

    .headerBtnDiv{
        height: 160px;
        width:120px;
        float:right;
        margin-right:80px;
        background: #5CACEE;
        border-radius: 3px;
        color: white;
        text-align:center;
        line-height: 160px;
        font-weight: 600;
        font-size: 20px;
    }
</style>
